package org.gdpu.Service.Impl;

import org.gdpu.Service.CampusService;
import org.gdpu.Service.CollegeService;
import org.gdpu.base.DaoSupport;
import org.gdpu.model.College;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by HEWI2 on 2/17/14.
 */

@Service
@Transactional
public class CollegeServiceImpl extends DaoSupport<College> implements CollegeService {

    private CampusService campusService;

    @Override
    public College findByCollegeByName(String college) {

        return this.find(College.class,college);
    }

    @Override
    public List<College> findCollegeByCampus(String campus) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("campus", campusService.findByCampusByName(campus));
        return this.findByFields(College.class, params);
    }

    @Resource(name = "campusServiceImpl")
    public void setCampusService(CampusService campusService) {
        this.campusService = campusService;
    }
}
